package mvc.utils;

import java.lang.reflect.Field;

import javax.servlet.http.HttpServletRequest;

import mvc.Beans.BaseBeans;



public class FillBean {
	
	public FillBean(){
		
	}
	
	public static BaseBeans doFill(String className, HttpServletRequest request){
		System.out.println("before doFill" + className);
		BaseBeans o = null;
		try{
			@SuppressWarnings("rawtypes")
			Class clz = Class.forName(className);
			o = (BaseBeans) clz.newInstance();
			Field [] fr = clz.getDeclaredFields();
			for(Field f: fr){
				f.setAccessible(true);
				f.set(o, request.getParameter(f.getName()));
				System.out.println("doingFill" + f.getName());
				f.setAccessible(false);
			}
			
		}catch(Exception ex){
		//	ex.printStackTrace();
		}
		System.out.println("after doFill" + className);
		System.out.println("after dofill  Object o is " + o);
		return o;
		
		
	}

}
